﻿namespace WMS6.Services
{
    using System;
    using System.Collections.Generic;
    using System.ServiceModel;
    using System.ServiceModel.Activation;
    using WMS6.BLL;
    using WMS6.Common;
    using WMS6.DataEntity;

    [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall), AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)]
    public class CommonMethodService2 : ICommonMethodService2
    {
        public List<SysCode4DDL> GetBaseInfoForDDLSource(string sourceFrom, PubParasInfo pubParasInfo)
        {
            CommonMethodBLL commonMethod = new CommonMethodBLL(pubParasInfo);
            return commonMethod.GetBaseInfoForDDLSource(sourceFrom);
        }

        public List<InvPalletInfo> GetInvPalletByIDAndType(string docID, string docType, PubParasInfo pubParasInfo)
        {
            try
            {
                InvPalletBLL invPalletBLL = new InvPalletBLL(pubParasInfo);
                return invPalletBLL.GetInvPalletByIDAndType(docID, docType);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "CommonMethodService异常");
            }
            return null;
        }

        public string InsertInvPallet(List<InvPalletInfo> invPalletListInfo, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                result = new InvPalletBLL(pubParasInfo).InsertInvPallet(invPalletListInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "CommonMethodService异常");
            }
            return result;
        }

        public string ReleasePrintControl(List<PrintControlInfo> printControlInfos, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                result = new CommonMethodBLL(pubParasInfo).ReleasePrintControl(printControlInfos);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "CommonMethodService异常");
            }
            return result;
        }

        public string SavePrintControl(List<PrintControlInfo> printControlInfos, PubParasInfo pubParasInfo)
        {
            string result = string.Empty;
            try
            {
                result = new CommonMethodBLL(pubParasInfo).SavePrintControl(printControlInfos);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "CommonMethodService异常");
            }
            return result;
        }

        public int UpdateASNAndSOSingleField(string orderType, string orderID, string updatedField, string value, PubParasInfo pubParasInfo)
        {
            int result = 0;
            try
            {
                result = new CommonMethodBLL(pubParasInfo).UpdateASNAndSOSingleField(orderType, orderID, updatedField, value);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "CommonMethodService异常");
            }
            return result;
        }

        public int UpdateDeclarations(string Type, string keyID, string ExternOrderID, string CoreReleaseID, string WorkOrder, PubParasInfo pubParasInfo)
        {
            int result = 0;
            try
            {
                result = new CommonMethodBLL(pubParasInfo).UpdateDeclarations(Type, keyID, ExternOrderID, CoreReleaseID, WorkOrder);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "CommonMethodService异常");
            }
            return result;
        }

        public int UpdateExternOrderID(string Type, string keyID, string ExternOrderID, PubParasInfo pubParasInfo)
        {
            int result = 0;
            try
            {
                result = new CommonMethodBLL(pubParasInfo).UpdateExternOrderID(Type, keyID, ExternOrderID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "CommonMethodService异常");
            }
            return result;
        }
    }
}

